package com.wmeimob.fastboot.jiubei.controller;

import com.github.pagehelper.PageInfo;
import com.wmeimob.fastboot.core.context.PageContext;
import com.wmeimob.fastboot.jiubei.entity.ShopGoodsComment;
import com.wmeimob.fastboot.jiubei.service.ShopGoodsCommentService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author wjt
 * @version 1.0
 * @className ShopGoodsCommentController
 * @description 【商品评价】控制器
 * @date Sat Aug 29 21:42:58 CST 2020
 **/
@RestController
@RequestMapping("shopGoodsComment")
@Slf4j
public class ShopGoodsCommentController {

    @Resource
    private ShopGoodsCommentService shopGoodsCommentService;


    /**
     * 商品评价分页查询
     *
     * @param shopGoodsComment
     * @return
     */
    @GetMapping
    public PageInfo queryForShopGoodsComment(ShopGoodsComment shopGoodsComment) {
        PageContext.startPage();
        return new PageInfo<ShopGoodsComment>(shopGoodsCommentService.list(shopGoodsComment));

    }

    /**
     * 商品评价导出
     *
     * @param shopGoodsComment
     * @return
     */
    @PostMapping("/export")
    public List<ShopGoodsComment> queryForShopGoodsCommentExport(@RequestBody ShopGoodsComment shopGoodsComment) {
        return shopGoodsCommentService.list(shopGoodsComment);
    }


    /**
     * 商品评价查询-<通过id查询>
     *
     * @param id
     * @return
     */
    @GetMapping("/{id}")
    public ShopGoodsComment queryForShopGoodsCommentById(@PathVariable("id") Object id) {
        return shopGoodsCommentService.queryShopGoodsCommentById(id);
    }


    /**
     * 商品评价添加
     *
     * @param shopGoodsComment
     * @return
     */
    @PostMapping
    public void insertForShopGoodsComment(@RequestBody ShopGoodsComment shopGoodsComment) {
        shopGoodsCommentService.addShopGoodsComment(shopGoodsComment);
    }


    /**
     * 商品评价修改
     *
     * @param shopGoodsComment
     * @return
     */
    @PutMapping
    public void updateForShopGoodsComment(@RequestBody ShopGoodsComment shopGoodsComment) {
        shopGoodsCommentService.modifyShopGoodsComment(shopGoodsComment);
    }

    /**
     * 商品评价删除
     *
     * @param id
     * @return
     */
    @DeleteMapping("/{id}")
    public void removeForShopGoodsComment(@PathVariable("id") Long id) {
        shopGoodsCommentService.removeShopGoodsComment(id);
    }
}
